//package com.jumi.microservice.rocketmq;
//
//import com.aliyun.openservices.ons.api.MessageListener;
//import com.aliyun.openservices.ons.api.PropertyKeyConst;
//import com.aliyun.openservices.ons.api.bean.ConsumerBean;
//import com.aliyun.openservices.ons.api.bean.Subscription;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.*;
//
//@Configuration
//public class ConsumerClient {
//
//    @Autowired
//    private RocketMqConfig mqConfig;
//
//    @Autowired
//    private RocketMessageListener messageListener;
//
//    @Bean(initMethod = "start", destroyMethod = "shutdown")
//    public ConsumerBean buildOrderConsumer() {
//        ConsumerBean orderConsumerBean = new ConsumerBean();
//        //配置文件
//        Properties properties = mqConfig.getMqProperties();
//        properties.setProperty(PropertyKeyConst.GROUP_ID, mqConfig.getGroup());
//        orderConsumerBean.setProperties(properties);
//        //订阅关系
//        Map<Subscription, MessageListener> subscriptionTable = new HashMap<Subscription, MessageListener>();
//        Subscription subscription = new Subscription();
//        subscription.setTopic(mqConfig.getTopic());
//        subscription.setExpression(mqConfig.getTag());
//        subscriptionTable.put(subscription, messageListener);
//        //订阅多个topic如上面设置
//        orderConsumerBean.setSubscriptionTable(subscriptionTable);
//        return orderConsumerBean;
//    }
//
//}
